package com.ly.web.controller.erp;

import java.util.List;

import com.ly.common.annotation.Log;
import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.AjaxResult;
import com.ly.common.core.page.TableDataInfo;
import com.ly.common.enums.BusinessType;
import com.ly.common.utils.poi.ExcelUtil;
import com.ly.heart.domain.KingAllocateDetailEntity;
import com.ly.heart.service.IKingAllocateDetailService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 调拨单明细Controller
 * 
 * @author wutao
 * @date 2024-08-07
 */
@RestController
@RequestMapping("/heart/allocateDetail")
public class KingAllocateDetailController extends BaseController
{
    @Autowired
    private IKingAllocateDetailService erpKingAllocateDetailService;

    /**
     * 查询调拨单明细列表
     */
    @PreAuthorize("@ss.hasPermi('heart:allocateDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(KingAllocateDetailEntity erpKingAllocateDetail)
    {
        startPage();
        List<KingAllocateDetailEntity> list = erpKingAllocateDetailService.selectErpKingAllocateDetailList(erpKingAllocateDetail);
        return getDataTable(list);
    }

    /**
     * 导出调拨单明细列表
     */
    @PreAuthorize("@ss.hasPermi('heart:allocateDetail:export')")
    @Log(title = "调拨单明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(KingAllocateDetailEntity erpKingAllocateDetail)
    {
        List<KingAllocateDetailEntity> list = erpKingAllocateDetailService.selectErpKingAllocateDetailList(erpKingAllocateDetail);
        ExcelUtil<KingAllocateDetailEntity> util = new ExcelUtil<KingAllocateDetailEntity>(KingAllocateDetailEntity.class);
        return util.exportExcel(list, "allocateDetail");
    }

    /**
     * 获取调拨单明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('heart:allocateDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(erpKingAllocateDetailService.selectErpKingAllocateDetailById(id));
    }

    /**
     * 新增调拨单明细
     */
    @PreAuthorize("@ss.hasPermi('heart:allocateDetail:add')")
    @Log(title = "调拨单明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KingAllocateDetailEntity erpKingAllocateDetail)
    {
        return toAjax(erpKingAllocateDetailService.insertErpKingAllocateDetail(erpKingAllocateDetail));
    }

    /**
     * 修改调拨单明细
     */
    @PreAuthorize("@ss.hasPermi('heart:allocateDetail:edit')")
    @Log(title = "调拨单明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KingAllocateDetailEntity erpKingAllocateDetail)
    {
        return toAjax(erpKingAllocateDetailService.updateErpKingAllocateDetail(erpKingAllocateDetail));
    }

    /**
     * 删除调拨单明细
     */
    @PreAuthorize("@ss.hasPermi('heart:allocateDetail:remove')")
    @Log(title = "调拨单明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(erpKingAllocateDetailService.deleteErpKingAllocateDetailByIds(ids));
    }
}
